import { Component } from "react";
import { View, Text } from "@tarojs/components";
import { AtButton } from "taro-ui";
import Taro from "@tarojs/taro";
import "taro-ui/dist/style/components/button.scss"; // 按需引入

import "./index.scss";

export default class Index extends Component {
  constructor() {
    super(...arguments);
    this.state = {
      msg: ""
    };
  }

  componentWillMount() {
    this.getTest();
  }

  componentDidMount() {}

  componentWillUnmount() {}

  componentDidShow() {}

  componentDidHide() {}

  render() {
    return (
      <View className="index">
        <Text>Hello world!</Text>
        <AtButton type="primary">I need Taro UI</AtButton>
        <Text>Taro UI 支持 Vue 了吗？</Text>
        <AtButton type="primary" circle>
          支持
        </AtButton>
        <Text>共建？</Text>
        <AtButton type="secondary" circle>
          来
        </AtButton>
        <Text>{this.state.msg}</Text>
      </View>
    );
  }
  getTest() {
    let that = this;
    Taro.request({
      url: "https://dmyg.xyz:3000/",
      method: "GET",

      success: function(res) {
        console.log(res);
        that.setState({
          msg: res.data
        });
      }
    });
  }
}
